1 : <?php
2 : /*--------------------------------------------------------------------------+
3 : This file is part of eStudy.
4 : news/classes/class.NewsCategoryMembers.inc.php
5 : - Modulgruppe: News
6 : - Beschreibung: Klasse für die News-Kategorie Portalmitglieder.
7 : - Version: 1.1.2.4, 24/01/08
8 : - Autor(en): Corinna Kropf <corinna.kropf@mni.fh-giessen.de>
9 : +---------------------------------------------------------------------------+
10 : This program is free software; you can redistribute it and/or
11 : modify it under the terms of the GNU General Public License
12 : as published by the Free Software Foundation; either version 2
13 : of the License, or any later version.
14 : +---------------------------------------------------------------------------+
15 : This program is distributed in the hope that it will be useful,
16 : but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : GNU General Public License for more details.
19 : You should have received a copy of the GNU General Public License
20 : along with this program; if not, write to the Free Software
21 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 : +--------------------------------------------------------------------------*/
23 :
24 1 : require_once ("class.newscategory.inc.php");
25 :
26 : /**
27 : * Klasse für die News-Kategorie Portalmitglieder.
28 : * @package eStudy.News
29 : * @version 1.1.2.4, 24/01/08
30 : * @author Corinna Kropf <corinna.kropf@mni.fh-giessen.de>
31 : */
32 1 : class NewsCategoryMembers extends NewsCategory
33 : {
34 : /**
35 : * Flag fuer die Anzeige der News-Eintraege
36 : * @var bool
37 : */
38 : private $dark;
39 : /**
40 : * HTML-Template
41 : * @var Template
42 : */
43 : private $newsTemplate;
44 : /**
45 : * Konstruktor
46 : */
47 : public function __construct($catID, $courses, $categorySettings = null)
48 : {
49 0 : parent::__construct($catID, $courses, $categorySettings);
50 0 : $this->newsTemplate = new Template(PATH_TO_ROOT."news/templates/newsannouncement.html");
51 0 : }
52 : /**
53 : * Überschreibt die Methode der Oberklasse,
54 : * um weitere Initialisierungen vor der Ausgabe zu machen.
55 : * @see NewsCategory
56 : */
57 : public function echoNews($courseID, $usergroup = null)
58 : {
59 0 : $this->dark = false;
60 0 : parent::echoNews($courseID, $usergroup);
61 0 : }
62 : /**
63 : * @see NewsCategory
64 : */
65 : public function isInstalled($courseID)
66 : {
67 0 : return true;
68 : }
69 : /**
70 : * @see NewsCategory
71 : */
72 : public function canSelectPeriod() {
73 0 : return true;
74 : }
75 : /**
76 : * @see NewsCategory
77 : */
78 : public function getNewsHeaderTitle($courseID = null, $type = null) {
79 0 : if ($courseID > 0) {
80 0 : if ( $type == 'ecom' )
81 0 : $prefix = "eCommunity";
82 : else
83 0 : $prefix = "Kurs";
84 0 : }
85 : else
86 0 : $prefix = "Portal";
87 :
88 0 : if(isset($this->news)) {
89 0 : $newsCount = $this->news["count"];
90 0 : if ($newsCount > 1)
91 0 : $title = sprintf( $this->translate->_("%1\$s neue %2\$s-Mitglieder"), $newsCount, $prefix);
92 0 : else if ($newsCount == 1)
93 0 : $title = sprintf( $this->translate->_("%1\$s neues %2\$s-Mitglied"), $newsCount, $prefix);
94 0 : }
95 : else
96 0 : $title = sprintf( $this->translate->_("Keine neuen %1\$s-Mitglieder"), $prefix);
97 :
98 0 : return $title;
99 : }
100 :
101 : /**
102 : * @see NewsCategory
103 : */
104 : protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = null) {
105 : // Neue Portal-/Kurs-Mitglieder
106 0 : if (isset($courseID) && isset($from) && isset($to) && isset($this->coursePreferences))
107 0 : {
108 0 : if(!is_numeric($courseID) || !is_numeric($from) || !is_numeric($to)) return null;
109 :
110 0 : global $db;
111 0 : $this->news = array();
112 :
113 0 : $timefrom = $this->getPeriod($courseID, $from);
114 0 : $timeto = $to;
115 :
116 0 : if ($courseID) {
117 : $sql = "SELECT ID, IF(differentUsergroup>0, differentUsergroup, Usergroup) AS Usergroup "
118 0 : ."FROM user, user_course "."WHERE userID=ID "
119 0 : ."AND courseID='".Data::toMysql($courseID)."' "
120 0 : ."AND regtime>='".$timefrom."' AND regtime<='".$timeto."'"
121 0 : ."AND Invisible=0 "
122 0 : ."ORDER BY Nachname, Vorname";
123 0 : } else {
124 : $sql = "SELECT ID, Usergroup "
125 0 : ."FROM user "."WHERE regdate>='".date("Y-m-d H:i:s", $timefrom) ."' AND regdate<='".date("Y-m-d H:i:s", $timeto)."'"
126 0 : ."AND Invisible=0 "
127 0 : ."ORDER BY Nachname, Vorname";
128 : }
129 0 : $this->news["data"] = $db->get_results($sql);
130 0 : if ($db->num_rows == 0) $this->news = null;
131 : else {
132 0 : foreach($this->news["data"] as $userID) $this->users[$userID->ID] = $userID->ID;
133 0 : $this->news["count"] = $db->num_rows;
134 : }
135 0 : }
136 :
137 0 : return $this->news;
138 : }
139 : /**
140 : * @see NewsCategory
141 : */
142 : protected function echoNewsEntry($entry, $courseID, $usergroup = null)
143 : {
144 0 : if(!isset($this->dark) || !isset($entry) || !isset($courseID) || !isset($this->news["user"])) return;
145 :
146 0 : $cellStyle = ($this->dark ? "Dark" : "");
147 : echo "<tr>"
148 0 : ."<td colspan='2' class='tableCell".$cellStyle ."'>"
149 0 : .Output::getUsergroupPicture($entry->ID, $entry->Usergroup, $courseID)
150 0 : ." "
151 0 : .$this->getProfileLink($this->news["user"], $entry->ID, $courseID)
152 0 : ."</td>"
153 0 : ."</tr>\n";
154 0 : $this->dark = !$this->dark;
155 0 : }
156 : }
|